package cn.tedu.exec;

/**
 * @author: Dsi
 * @date: 2021/11/10 17:18
 * @description:
 */
public class TestAnimal {
    public static void main(String[] args) {
        Bird b=new Pigeon();
        b.fly();
        b.layEgg();
        Bird b2=new Swallow();
        b2.layEgg();
        System.out.println("-----------------------");
        Insect  i=new Ant();
        i.layEgg();
        i.fly();
        Insect i2=new Bee();
        i2.layEgg();
        Bee b1=new Bee();
        b1.beeFi();
    }
}
abstract class Bird{
    //成员常量，腿的数量
    final int LEG_NUMBERS =2;
    //下蛋的数量，成员变量
    int eggNumbers;
    public void fly(){//
        System.out.println("小鸟飞啊飞");
    }
    public abstract void layEgg();
}
class Pigeon extends Bird{
    @Override
    public void layEgg() {
        eggNumbers=10;
        System.out.println("鸽子下"+eggNumbers+"个蛋");
    }
}
class Swallow extends Bird{
    public void makeNest(){
        System.out.println("燕子会筑巢");
    }
    @Override
    public void layEgg() {
        System.out.println("燕子会下6个蛋");
    }
}
abstract class Insect{
    final int LEG_NUMBER=6;
    int layEgg;
    public void fly(){
        System.out.println("昆虫父类飞呀飞");
    }
    public abstract void layEgg();
}
class Ant extends Insect{
    @Override
    public void layEgg() {
        layEgg=15;
        System.out.println("蚂蚁子类产卵数量："+layEgg);
    }
}
class Bee extends Insect{
    @Override
    public void layEgg() {
        layEgg=666;
        System.out.println("子类蜜蜂下蛋数量："+layEgg);
    }
    public void beeFi(){
        System.out.println("我是子类蜜蜂，我还会筑巢");
    }
}